<script src="../../../../resources/testharness.js"></script>
<script src="../../../../resources/testharnessreport.js"></script>

<script> 
canvas = document.createElement('canvas');

function tryMimeType(t, mimeType, expectedMimeType)
{
    canvas.toBlob(function(blob) {
        t.step_func(function() {
            assert_true(blob.type === expectedMimeType);
        });
        t.done();
    }, mimeType);
}

async_test(t => {
    tryMimeType(t, "image/PNG", "image/png");
}, "Test that toBlob(mimeType) ignores the case of 'mimeType' (PNG).");

async_test(t => {
    tryMimeType(t, "imaGE/jpEg", "image/jpeg");
}, "Test that toBlob(mimeType) ignores the case of 'mimeType' (JPEG).");

async_test(t => {
    tryMimeType(t, "ImAgE/WeBp", "image/webp");
}, "Test that toBlob(mimeType) ignores the case of 'mimeType' (WEBP).");

async_test(t => {
    // Unsupported mime type falls back to png
    tryMimeType(t, "image/bmp", "image/png");
}, "Test that unsupported mime type falls back to png.");

</script>
